package bookstore;

import java.time.LocalDateTime;
import java.util.Random;
import java.util.Scanner;

public class BookStore {
    static Book[] books = new Book[4];


    static {
        books[0] = new Book(1, "红楼梦", 50, 20);
        books[1] = new Book(2, "水浒传", 40, 10);
        books[2] = new Book(3, "三国演义", 30, 10);
        books[3] = new Book(4, "西游记", 20, 10);
    }

    public static void main(String[] args) {
        showbook(books);
        Person p=new Person("张飞");
        Book book=p.buybook1(books);
        showTotal(book,p);

    }

    private static void showbook(Book[] books) {
        System.out.println("图书编号  图书名称  图书价格  库存数量");
        for (int i = 0; i < 4; i++) {
            System.out.println(books[i].getId()+"\t\t"+books[i].getName()+"\t\t"+books[i].getPrice()+"\t\t"+books[i].getStorage());

        }
    }

    public static void showTotal(Book book,Person p) {
        Scanner sc=new Scanner(System.in);
        for (int i = 0; i < 4; i++) {


        }


        Random random=new Random();
        int orderNum=random.nextInt();
        System.out.println("订单编号"+Math.abs(orderNum));
        System.out.println("购物时间"+ LocalDateTime.now());
        System.out.println("会员"+p.getName());
        System.out.println("图书名称"+book.getName());
        System.out.println("总价格"+p.getSum());


    }

}
